package com.dk.serviceimpl;
import com.dk.mapper.TProductMapper;
import com.dk.mapper.TTypeMapper;
import com.dk.pojo.TProduct;
import com.dk.pojo.TProductExample;
import com.dk.pojo.TType;
import com.dk.service.TProductService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
  public class TProductServiceImpl implements TProductService {
    @Autowired
    private TProductMapper tProductMapper;
    @Autowired
    private TTypeMapper tTypeMapper;

    //查询
    @Override
    public PageInfo<TProduct> selectAll(Integer pageNum, Integer pageSize, TProduct tProduct) {
        PageHelper.startPage(pageNum, pageSize);
        List<TProduct> list = tProductMapper.getInfo(tProduct);
        PageInfo<TProduct> page = new PageInfo<>(list);
        return page;
    }

    @Override
    public void deleteS(String[] ids) {
        tProductMapper.deleteByS(ids);
    }

    @Override
    public TProduct selectId(Integer id) {
        TProduct tProduct = tProductMapper.selectByPrimaryKey(id);
        return tProduct;
    }

    @Override
    public List<TType> selectType() {
        List<TType> tTypes = tTypeMapper.selectByExample(null);
        return tTypes;
    }

    @Override
    public Integer updateBy(TProduct t) {
        int i = tProductMapper.updateByPrimaryKey(t);
        return i;
    }
}


